<template>
	<view class="work-container">
		

			<view @click="codeScan" class="submitButton">
				<uni-icons type="scan" size="80" color="#fff"></uni-icons>
			</view>
		

	</view>

</template>

<script>
	import{ addPigOut }from "@/api/hmy/pigOut.js"
	export default {
		name: "saomachadang",
		data() {
			return {
				pigCode:''
			};
		},
		onReady() {
		  //this.$refs.form.setRules(this.rules)
		},
		created() {

		},
		methods: {
			codeScan() {
				//console.log(form);
				var _this = this;
				uni.scanCode({
					onlyFromCamera: true, //为true只允许相机扫码，不加允许相册扫码
					success: function(res) {
						let pigData = JSON.parse(String(res.result));
						_this.pigCode = pigData.pigCode
						_this.$tab.navigateTo('/pages/hmy/pig/pigDetials?pigCode=' + _this.pigCode);
						// addPigOut(form).then(res =>{
						// 	uni.showToast({
						// 		title: '扫码成功'
						// 	})
						// })
					},
					fail: function(err) {
						console.log('扫码失败', err)
					}
				})
			},
			
		}

	}
</script>

<style lang="scss">
	/* #ifndef APP-NVUE */
	page {
		display: flex;
		flex-direction: column;
		box-sizing: border-box;
		min-height: 100%;
		height: auto;
		background-color: #fcfcfc;
	}

	view {
		font-size: 16px;
		line-height: inherit;
	}

	/* #endif */
	.code {
		margin-bottom: 5px;
	}

	.icon {
		float: right;
		margin-right: 10px;
		margin-top: 5px;
	}

	.message {
		margin-top: 5px;
		color: #989897;
		line-height: 25px;
	}
	.example {
	  padding: 15px;
	  background-color: #fff;
	}
	.submitButton{
		width:fit-content;
		margin: 0 auto;
		padding: 10px;
		border-radius: 50%;
		background-color: #04BE02;
	}
</style>
